<template>
  <page-header-wrapper>
    <page-tab-list>
      <a-alert message="此配置用于设置网站版权" type="info" show-icon style="margin: 24px 0" />
      <a-form-model ref="appForm" :model="copyrightSetting" :labelCol="{ span: 3 }" :wrapperCol="{ span: 7 }">
        <a-form-model-item label="网站名称" prop="web_name">
          <a-input v-model="copyrightSetting.web_name" placeholder="请填写网站名称" />
        </a-form-model-item>
        <a-form-model-item label="Logo图片URL" prop="web_log">
          <cyyUploadImg
            @uploadSuccess="
              (e) => {
                copyrightSetting.web_log = e.data
              }
            "
            @deleteImg="copyrightSetting.web_log = ''"
            :imgSrc="copyrightSetting.web_log"
            imgSizeText="100*100"
          >
          </cyyUploadImg>
        </a-form-model-item>
        <a-form-model-item label="底部版权信息" prop="copyright">
          <a-textarea v-model="copyrightSetting.copyright" placeholder="请填写底部版权信息" :rows="4" />
        </a-form-model-item>
        <a-form-model-item label="登录页背景图" prop="passport_bg">
          <cyyUploadImg
            @uploadSuccess="
              (e) => {
                copyrightSetting.passport_bg = e.data
              }
            "
            @deleteImg="copyrightSetting.passport_bg = ''"
            :imgSrc="copyrightSetting.passport_bg"
            imgSizeText="750*1334"
          >
          </cyyUploadImg>
        </a-form-model-item>
        <!-- <a-form-model-item label="商城分享标题" prop="store_share_title">
          <a-input v-model="copyrightSetting.store_share_title" placeholder="请填写商城分享标题" />
        </a-form-model-item>
        <a-form-model-item label="商城分享缩略图" prop="store_share_logo">
          <cyyUploadImg
            @uploadSuccess="
              (e) => {
                copyrightSetting.store_share_logo = e.data
              }
            "
            @deleteImg="copyrightSetting.store_share_logo = ''"
            :imgSrc="copyrightSetting.store_share_logo"
            imgSizeText="100*100"
          >
          </cyyUploadImg>
        </a-form-model-item>
        <a-form-model-item label="商城分享描述" prop="store_share_desc">
          <a-input v-model="copyrightSetting.store_share_desc" placeholder="请填写商城分享描述" />
        </a-form-model-item> -->
        <a-form-model-item :wrapper-col="{ span: 7, offset: 2 }">
          <a-button :loading="btnLoading" type="primary" @click="submitForm"> 保存 </a-button>
        </a-form-model-item>
      </a-form-model>
    </page-tab-list>
  </page-header-wrapper>
</template>
<script>
import { settingCopyright, getCopyrightSetting } from '@/api/store'
import { cyyUploadImg } from '@/components/CyyUi'

export default {
  name: 'SettingCopyright',
  components: {
    cyyUploadImg,
  },
  data() {
    return {
      loading: false,
      copyrightSetting: {
        web_name: '',
        web_log: '',
        copyright: '',
        passport_bg: '',
        // store_share_title: '',
        // store_share_logo: '',
        // store_share_desc: '',
      },
      btnLoading: false,
      fix: true,
    }
  },
  created() {
    this.getData()
  },
  methods: {
    getData: function () {
      this.loading = true
      getCopyrightSetting({})
        .then((res) => {
          if (res.code == 0) {
            this.fix = false
            this.$nextTick(() => {
              this.copyrightSetting = res.data
              this.fix = true
            })
          }
        })
        .catch((error) => {
          console.log(error)
        })
        .then(() => {
          this.loading = false
        })
    },
    submitForm: function () {
      this.btnLoading = true
      settingCopyright(this.copyrightSetting)
        .then((res) => {
          if (res.code == 0) {
            this.$message.success(res.msg)
          } else {
            this.$message.warning(res.msg)
          }
        })
        .catch((error) => {
          console.log(error)
        })
        .then(() => {
          this.btnLoading = false
        })
    },
  },
}
</script>
<style scoped></style>
